package cn.smile.controller.msg;

import cn.smile.bean.dto.msg.NoticeDTO;
import cn.smile.bean.form.msg.notice.NoticeAddForm;
import cn.smile.business.msg.INoticeService;
import cn.smile.commons.response.MyResult;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/notice")
public class NoticeController {

    @Resource
    private INoticeService service;

    @PostMapping(value = "addNotice")
    public MyResult<Boolean> addNotice(@Valid @RequestBody NoticeAddForm form) {
        return MyResult.OK(service.addNotice(form));
    }

    @GetMapping(value = "getMyNotice")
    public MyResult<NoticeDTO> getMyNotice() {
        return MyResult.OK(service.getMyNotice());
    }

    @GetMapping(value = "readNotice")
    public MyResult<Boolean> readNotice(@RequestParam("id") String id) {
        return MyResult.OK(service.readNotice(id));
    }
}
